﻿@{
    ViewData["Title"] = "register";
}

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="~/css/table.css" rel="stylesheet" />
    <script src="~/echarts/echarts.min.js"></script>
    <style type="text/css">
        <!--
        .style3 {
            color: #0000CC
        }

        td {
            text-align: center
        }
        -->
    </style>
</head>
<div id="app">
    <table width="100%">
        <tr>
            <td colspan="2" style="text-align: left">
                <font color="black">
                    您正在做的业务是：人力资源--薪酬标准管理--薪酬发放复核
                </font>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: right;">
                <input type="submit" value="提交" class="BUTTON_STYLE1" v-on:click="EditsgDetail()">
                <input type="button" value="返回" onclick="javascript:window.history.back();" class="BUTTON_STYLE1">
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: left">
                薪酬单编号：@ViewData["sgrantID"]
                <input type="hidden" name="salaryGrant.salaryGrantId" value="@ViewData["sgrantID"]">
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" id="sgrantID" value="@ViewData["sgrantID"]" hidden="hidden" />
                <input type="text" id="standardID" value="@ViewData["standardID"]" hidden="hidden" />
            </td>
        </tr>
        <tr>
            <td style="text-align: left">
                本机构总人数:@ViewData["human_amount"]
                <input type="hidden" name="salaryGrant.humanAmount" value="5">
                ,基本薪酬总数:@ViewData["standardSum"]<input type="hidden" name="salaryGrant.salaryStandardSum" value="@ViewData["standardSum"]" />
                ,实发总额:<span id="salarySum_sum">@ViewData["paidSum"]</span>
                <input type="hidden" id="salaryPaidSum" name="salaryGrant.salaryPaidSum" value="@ViewData["paidSum"]" />
            </td>
            <td style="text-align: right;">
                登记人:<input type="text" name="salaryGrant.register" value="better_admin" size="8" readonly="readonly">
                登记时间：<span id="Tdate"></span>
                <input type="hidden" name="salaryGrant.registTime" id="Tdate2">
            </td>
        </tr>
    </table>
    <form role="form" id="frmSalary">
        <table width="100%" border="1" cellpadding=0 cellspacing=1
               bordercolorlight=#848284 bordercolordark=#eeeeee
               class="TABLE_STYLE1">
            <tr>
                <td class="TD_STYLE1">
                    <span>序号</span>
                </td>
                <td class="TD_STYLE1">
                    <span>档案编号</span>
                </td>
                <td class="TD_STYLE1">
                    <span>姓名</span>
                </td>
                <td class="TD_STYLE1">
                    <span>酬薪基本明细</span>
                </td>
                <td class="TD_STYLE1" hidden="hidden">
                    <span>标准薪酬总额</span>
                </td>
                <td class="TD_STYLE1" hidden="hidden">
                    <span>薪酬发放编号</span>
                </td>

                <td class="TD_STYLE1" width="7%">
                    奖励金额
                </td>
                <td class="TD_STYLE1" width="7%">
                    销售绩效总额
                </td>
                <td class="TD_STYLE1" width="7%">
                    应扣金额
                </td>
                <td class="TD_STYLE1" width="7%">
                    实发金额
                </td>
            </tr>
            <tbody id="tbody" v-for="(item,index) in dt">
                <tr class="TD_STYLE2">
                    <td>
                        <input type="hidden" :id="'grd_id'+index" name="grd_id" v-model="item.grd_id" />
                        {{item.grd_id}}
                    </td>
                    <td>
                        <input type="hidden" name="human_id" :id="'human_id'+index" v-model="item.human_id" />
                        {{item.human_id}}
                    </td>
                    <td>
                        <input type="hidden" name="human_name" :id="'human_name'+index" v-model="item.human_name" />
                        {{item.human_name}}
                    </td>
                    <td>
                        <a href="#" v-on:click="SelssDetails([item.human_id])">详细内容</a>
                    </td>
                    <td hidden="hidden">
                        <input name="salary_standard_sum" :id="'salary_standard_sum'+index" :value="@ViewData["standardSum"]" />

                    </td>
                    <td hidden="hidden">
                        <input :id="'salary_standard_id'+index" name="salary_standard_id" :value="@ViewData["sgrantID"]" hidden="hidden" />
                    </td>

                    <td>
                        <input type="text" name="grantDetails[0].bounsSum" :id="'bounsSum'+index" v-on:keyup="onKeyPress(index)" class="INPUT_STYLE2" />
                    </td>
                    <td>
                        <input type="text" name="grantDetails[0].saleSum" :id="'saleSum'+index" v-on:keyup="onKeyPress(index)" class="INPUT_STYLE2" />
                    </td>
                    <td>
                        <input type="text" name="grantDetails[0].deductSum" :id="'deductSum'+index" v-on:keyup="onKeyPress(index)" class="INPUT_STYLE2" />
                    </td>
                    <td>
                        <input type="text" name="grantDetails[0].salaryPaidSum" readonly="readonly" :id="'salaryPaidSum'+index" v-model="item.salary_paid_sum" class="INPUT_STYLE2" />
                    </td>
                </tr>
                <input type="hidden" name="grantDetails[0].salaryGrantId" value="@ViewData["sgrantID"]">
                <input type="hidden" :id="'salaryStandardSum'+index" name="grantDetails[0].salaryStandardSum" v-model="item.salary_paid_sum" />

            </tbody>
        </table>
        <div class="modal fade" id="mySel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <h4 class="modal-title" id="myModalLabel">
                        薪酬标准单详细信息
                    </h4>
                    <div class="modal-body">
                        <div id="main" style="width: 600px;height:400px;"></div>
                    </div>
                </div>
            </div>
        </div>

    </form>

</div>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            dt: [],
            dt2: [],
            leng: 0,
            Sdt: []
        },
        methods: {
            load: function () {
                var t = this;
                var sgid = $("#sgrantID").val();
                $.ajax({
                    url: "/salaryGrant/check?sgrantID=" + sgid,
                    type: "post",
                    success: function (msg) {
                        var d = eval(msg);
                        t.dt = d["dt"];
                        t.leng = d["leng"];
                    }
                });
            },
            SelssDetails: function () {
                var t = this;
                var stid = $("#standardID").val();

                $("#mySel").modal('show');
                var t = this;
                $.ajax({
                    url: "/salaryGrant/ssDetails2?standardID=" + stid,
                    type: "get",
                    success: function (msg) {
                        var df = eval("(" + msg + ")");
                        t.dt1 = df["name"];
                        t.Sdt = df["salary"];
                        myChart.setOption({
                            legend: {
                                orient: 'vertical',
                                data: t.dt1
                            },
                            series: [{
                                name: '薪酬',
                                data: [
                                    { value: t.Sdt[0], name: t.dt1[0] },
                                    { value: t.Sdt[1], name: t.dt1[1] },
                                    { value: t.Sdt[2], name: t.dt1[2] },
                                    { value: t.Sdt[3], name: t.dt1[3] },
                                    { value: t.Sdt[4], name: t.dt1[4] },
                                    { value: t.Sdt[5], name: t.dt1[5] },
                                    { value: t.Sdt[6], name: t.dt1[6] },
                                ]
                            }]
                        });
                    }
                })
                var myChart = echarts.init(document.getElementById('main'));
                var option = {
                    tooltip: {
                        trigger: 'item',
                        formatter: '{a} <br/>{b}: {c} ({d}%)'
                    },
                    legend: {
                        orient: 'vertical',
                        left: 10,
                        data: ['薪酬']
                    },
                    series: [
                        {
                            name: '薪酬',
                            type: 'pie',
                            radius: ['50%', '70%'],
                            avoidLabelOverlap: false,
                            label: {
                                show: false,
                                position: 'center'
                            },
                            emphasis: {
                                label: {
                                    show: true,
                                    fontSize: '30',
                                    fontWeight: 'bold'
                                }
                            },
                            labelLine: {
                                show: false
                            },
                            data: [
                                { value: 1, name: '2' }
                            ]
                        }
                    ]
                };
                myChart.setOption(option);
            },
            EditsgDetail: function () {
                var t = this;
                for (var i = 0; i < t.leng; i++) {
                    //var grd_id = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(1) input").val();
                    //var human_id = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(2) input").val();
                    //var human_name = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(3) input").val();
                    //var salary_standard_sum = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(5) input").val();
                    //var salary_grant_id = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(6) input").val();
                    //var bouns_sum = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(7) input").val();
                    //var sale_sum = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(8) input").val();
                    //var deduct_sum = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(9) input").val();
                    //var salary_paid_sum = $("#tbody tr:nth-child(" + (i + 1) + ") td:nth-child(10) input").val();

                    var grd_id = document.getElementById("grd_id" + i).value;
                    var human_id = document.getElementById("human_id" + i).value;
                    var human_name = document.getElementById("human_name" + i).value;
                    var salary_standard_sum = document.getElementById("salary_standard_sum" + i).value;
                    var salary_grant_id = document.getElementById("salary_standard_id" + i).value;
                    var bouns_sum = document.getElementById("bounsSum" + i).value;
                    var sale_sum = document.getElementById("saleSum" + i).value;
                    var deduct_sum = document.getElementById("deductSum" + i).value;
                    var salary_paid_sum = document.getElementById("salaryPaidSum" + i).value;
                    $.ajax({
                        url: "/salaryGrant/EditsgDetail2",
                        type: "post",
                        data: {
                            "grd_id": grd_id, "salary_grant_id": salary_grant_id, "human_id": human_id, "human_name": human_name,
                            "bouns_sum": bouns_sum, "sale_sum": sale_sum, "deduct_sum": deduct_sum, "salary_standard_sum": salary_standard_sum, "salary_paid_sum": salary_paid_sum
                        },
                        success: function (msg) {
                            if (msg > 0) {
                                t.EditeGrant();
                            }
                        }
                    });
                }
            },
            EditeGrant: function () {
                $.ajax({
                    url: "/salaryGrant/EditeGrant2",
                    type: "post",
                    data: $("#frmSalary").serialize(),
                    success: function (msg) {
                        if (msg > 0) {
                            alert("复核成功!");
                            location.href = '/salaryGrant/query_locate';
                        } else {
                            alert("登记失败!");
                        }
                    }
                });
            },
            onKeyPress: function (i) {
                var size = this.leng;
                var bounsSum = document.getElementById("bounsSum" + i);
                var saleSum = document.getElementById("saleSum" + i);
                var deductSum = document.getElementById("deductSum" + i);
                var salaryPaidSum = document.getElementById("salaryPaidSum" + i);
                var salaryStandardSum = document.getElementById("salaryStandardSum" + i);
                if (isNaN(bounsSum.value) || bounsSum.value < 0) {
                    alert("金额填写错误!");
                    bounsSum.value = "0.00";
                }
                if (isNaN(saleSum.value) || saleSum.value < 0) {
                    alert("金额填写错误!");
                    saleSum.value = "0.00";
                }
                if (isNaN(deductSum.value) || deductSum.value < 0) {
                    alert("金额填写错误!");
                    deductSum.value = "0.00";
                }
                salaryPaidSum.value = Number(salaryStandardSum.value) + Number(bounsSum.value) + Number(saleSum.value) - Number(deductSum.value);

                var sum = 0;
                for (var j = 0; j <= size - 1; j++) {
                    sum = Number(sum) + Number(document.getElementById("salaryPaidSum" + j).value);
                }
                document.getElementById("salaryPaidSum" + i).innerHTML = salaryPaidSum.value;
                document.getElementById("salarySum_sum").innerHTML = sum;

            }
        },
        mounted: function () {
            this.load();
        }
    });
    //function onKeyPress(i) {

    //    var size = 5;
    //    var bounsSum = document.getElementById("bounsSum" + i);
    //    var saleSum = document.getElementById("saleSum" + i);
    //    var deductSum = document.getElementById("deductSum" + i);
    //    var salaryPaidSum = document.getElementById("salaryPaidSum" + i);
    //    if (isNaN(bounsSum.value) || bounsSum.value < 0) {
    //        alert("金额填写错误!");
    //        bounsSum.value = "0.00";
    //        return;
    //    }
    //    if (isNaN(saleSum.value) || saleSum.value < 0) {
    //        alert("金额填写错误!");
    //        saleSum.value = "0.00";
    //        return;
    //    }
    //    if (isNaN(deductSum.value) || deductSum.value < 0) {
    //        alert("金额填写错误!");
    //        deductSum.value = "0.00";
    //        return;
    //    }
    //    salaryPaidSum.value = Number(bounsSum.value) + Number(saleSum.value) - Number(deductSum.value) + Number(document.getElementById("salaryStandardSum" + i).value);

    //    var sum = 0;
    //    for (var j = 1; j <= size; j++) {
    //        sum = Number(sum) + Number(document.getElementById("salaryPaidSum" + j).value);
    //    }
    //    document.getElementById("salarySum_sum").innerHTML = sum;
    //    document.getElementById("salaryPaidSum").value = sum;

    //}

    function time() {
        var tdate = document.getElementById("Tdate");
        var d = new Date();
        var y = d.getFullYear();
        var moth = d.getMonth() + 1;
        var date = d.getDate();
        var h = d.getHours();
        var m = d.getMinutes();
        var s = d.getSeconds();
        var hh = 20 - 1 - h;
        var mm = 60 - 1 - m;
        var ss = 60 - s;
        if (hh > 0) {
            mm = mm + 60 * hh;
        }
        if (moth < 10) {
            moth = "0" + moth;
        }
        if (date < 10) {
            date = "0" + date;
        }
        if (h < 10) {
            h = "0" + h;
        }
        if (m < 10) {
            m = "0" + m;
        }
        if (s < 10) {
            s = "0" + s;
        }
        if (mm < 10) {
            mm = "0" + mm;
        }
        if (ss < 10) {
            ss = "0" + ss;
        }

        tdate.innerHTML = y + "-" + moth + "-" + date + " " + h + ":" + m + ":" + s;
        document.getElementById("Tdate2").value = tdate.innerHTML;
    }
    window.onload = time;
    var out = window.setInterval(time, 1000);
</script>













